﻿@using ST.Buz.Base.ViewModel
@model VM_Login
@{
    Layout = null;
}
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,minimum-scale=1,maximum-scale=1,viewport-fit=cover">
    <title>@ViewBag.SysName</title>
    <script src="~/lib/jquery-1.12.4.min.js" asp-append-version="true"></script>
    <script src="~/lib/math-6.1.0.min.js" asp-append-version="true"></script>
    <!-- 引入样式文件 -->
    <link rel="stylesheet" href="~/css/index.css" rel="stylesheet" />
    @*     <link rel="stylesheet"
          href="https://cdn.jsdelivr.net/npm/vant@2.2/lib/index.css" /> *@
    <!-- 引入 Vue 和 Vant 的 JS 文件 -->
    <script src="~/js/vue.min.js"></script>
    <script src="~/js/vant.min.js"></script>
    @*     <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vant@2.2/lib/vant.min.js"></script> *@
    <script src="~/js/app.js"></script>

    <script>
        var globalData = {
            modules: [],
            user: {},
            baseUrl: '@(Context.Request.PathBase)',
            todoList: [],
            todoIndex:0,
            loginUrl: '@(Url.Action("Login", "Sys_User"))',
        };
    </script>
    <style>
        html {
            background-color: #f7f7f7;
        }
        #app {
            padding-top: 46px;
            padding-bottom: 60px;
        }

        .van-doc-demo-block {
            padding: 0 16px;
        }

        .van-doc-demo-block__title {
            margin: 0;
            padding: 16px 0;
            color: #323233;
            font-weight: normal;
            font-size: 14px;
        }

        .bottombutton {
            padding: 10px;
        }
    </style>
</head>
<body>
    <div id="app">
        <van-nav-bar title="登录"
                     :fixed="true"
                     left-arrow
                     @@click-left="goBack">
        </van-nav-bar>
        <div class="page">
                <van-cell-group>
                    <van-field v-model="ucode" label="用户名" placeholder="请输入用户名"></van-field>
                    <van-field v-model="upasswd" type="password" label="密码" placeholder="请输入密码"></van-field>
                </van-cell-group>
                <div class="bottombutton">
                    <van-button type="primary" block @@click="login" :disabled="logging">登 录</van-button>
                </div>
        </div>
    </div>
    <script type="text/javascript">
        localStorage.clear();
        sessionStorage.clear();
        var pageApp = new Vue({
             el: '#app',
                data: {
                    ucode: '',
                    upasswd: '',
                    logging: false
                },
                methods: {
                    goBack(){
                        window.location.href = '@(Url.Action("MobileIndex", "Home"))';
                    },
                login: function (e) {
                    const _this=this;
                    if(!_this.ucode||_this.ucode.length<1)
                    {
                        vant.Toast('请输入用户名');
                        return;
                    }
                    if(!_this.upasswd||_this.upasswd.length<1)
                    {
                        vant.Toast('请输入密码');
                        return;
                    }
                    _this.logging = true;
                    utils.ajaxPost('@Url.Action("Login", "Sys_User")', { ucode: _this.ucode, upasswd: _this.upasswd }, function (resp) {
                        _this.logging = false;
                        localStorage.setItem(globalData.baseUrl+"uinfo", JSON.stringify(resp.data));
                        location.href='@Url.Action("MobileIndex", "Home")';
                    }, function (msg) {
                        _this.logging = false;
                        vant.Toast(msg || "登录失败，请检查参数或稍后再试");
                    });
                }
                },
        });
        // $(function () {
        //     var uinfo = localStorage.getItem('uinfo');
        //     if (!uinfo) {
        //         top.location.href = '@(Url.Action("MobileLogin", "Sys_User"))';
        //     } else {
        //         globalData.user = JSON.parse(uinfo);
        //     }
        // });
    </script>
</body>
</html>